package com.meilingcloud.common.enums;

import org.apache.commons.lang3.StringUtils;

public enum DateType {

    HOUR("h", "小时"),
    DAY("d", "天"),
    WEEK("w", "周"),
    MONTH("m", "月"),
    YEAR("y", "年"),
    ;

    private final String code;
    private final String info;

    DateType(String code, String info) {
        this.code = code;
        this.info = info;
    }

    public static DateType getTypeByCode(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (DateType type : DateType.values()) {
            if (type.getCode().equals(value)) {
                return type;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getInfo() {
        return info;
    }

}
